package com.slz.crm.server.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.slz.crm.pojo.entity.SalesOpportunityEntity;
import org.apache.ibatis.annotations.*;

import java.util.Set;

/**
 * 销售机会Mapper
 */
@Mapper
public interface SalesOpportunityMapper extends BaseMapper<SalesOpportunityEntity> {
    /**
     * 根据ID删除销售机会
     * @param id 销售机会ID
     * @return 删除结果
     */
    @Delete("delete from sales_opportunity where id = #{id} and stage = 5")
    boolean deleteById(Long id);

    /**
     * 根据名称模糊查询销售机会ID
     * @param opportunityName 销售机会名称
     * @return 销售机会ID集合
     */
    @Select("select id from sales_opportunity where opportunity_name like concat ('%', #{opportunityName}, '%') ")
    Set<Long> selectOpportunityIdsByName(String opportunityName);
}
